package com.ByteDance.model.vo;

import com.ByteDance.utils.StatusConstant;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * 用户登录注册返回对象
 * */
@Data
@ApiModel(description = "用户VO实体")
public class UserVO {
    @JsonIgnore //如果您在UserVO中注入了一个Bean，并且不希望它在JSON中显示，您可以使用Jackson库中的@JsonIgnore注解来标记该属性。@JsonIgnore注解会告诉Jackson在序列化对象为JSON时忽略该属性。
    @Autowired
    private StatusConstant.StatusEnum statusEnum;

    @Setter(onMethod_ = {@JsonProperty("status_code")})
    @ApiModelProperty("状态码，0-成功，其他值-失败")
    private Integer statusCode;

    @Setter(onMethod_ = {@JsonProperty("status_msg")})
    @ApiModelProperty("状态描述")
    private String statusMsg;

    @Setter(onMethod_ = {@JsonProperty("user_id")})
    @ApiModelProperty("用户id")
    private Integer userId;

    @ApiModelProperty("用户鉴权token")
    private String token;

    public static UserVO success(){
        UserVO userVO = new UserVO();
        userVO.setStatusCode(StatusConstant.StatusEnum.SUCCESS.getCode());
        userVO.setStatusMsg(StatusConstant.StatusEnum.SUCCESS.getMsg());
        return userVO;
    }

    public static UserVO fail(){
        UserVO userVO = new UserVO();
        userVO.setStatusCode(StatusConstant.StatusEnum.FAIL.getCode());
        userVO.setStatusMsg(StatusConstant.StatusEnum.FAIL.getMsg());
        return userVO;
    }
}
